home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / dma.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  5.8 KB  |  207 lines

  1. /*      DMA.H
  2.  *
  3.  * DMA handling routines
  4.  *
  5.  * $Id: dma.h,v 1.2 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16.  
  17. #ifndef __DMA_H
  18. #define __DMA_H
  19.  
  20.  
  21.  
  22. /****************************************************************************\
  23. *       struct dmaBuffer
  24. *       ----------------
  25. * Description:  DMA playing buffer
  26. \****************************************************************************/
  27.  
  28. typedef struct
  29. {
  30. #ifdef __16__
  31.     unsigned    bufferSeg;              /* DMA buffer segment (offset is
  32.                                            zero) */
  33. #endif
  34. #ifdef __PROTMODE__
  35.     unsigned    dosSeg;                 /* DMA buffer DOS segment */
  36.     unsigned    dpmiSel;                /* DMA buffer DPMI selector */
  37. #endif
  38.     ulong       startAddr;              /* buffer physical start address */
  39.     unsigned    bufferLen;              /* DMA buffer length in bytes */
  40.     void        *memBlk;                /* internal, used for unallocating */
  41.     int         channel;                /* channel on which the buffer is
  42.                                            being played or -1 */
  43. #if defined(__PROTMODE__) && !defined(__FLATMODE__)
  44.     void far    *dataPtr;               /* pointer to DMA buffer data */
  45. #else
  46.     void        *dataPtr;               /* pointer to DMA buffer data *//*!!*/
  47. #endif
  48. } dmaBuffer;
  49.  
  50.  
  51.  
  52.  
  53. /****************************************************************************\
  54. *       struct dmaChannel
  55. *       -----------------
  56. * Description:  DMA channel data used by DMA functions.
  57. \****************************************************************************/
  58.  
  59. typedef struct
  60. {
  61.     unsigned    number;                 /* DMA channel number */
  62.     unsigned    bit;                    /* DMA channel bit for registers */
  63.     unsigned    baseAddr;               /* base address port */
  64.     unsigned    wordCount;              /* word count port */
  65.     unsigned    request;                /* request port */
  66.     unsigned    singleMask;             /* mask port */
  67.     unsigned    mode;                   /* mode port */
  68.     unsigned    clearFF;                /* clear flip-flop port */
  69.     unsigned    page;                   /* page port */
  70. } dmaChannel;
  71.  
  72.  
  73.  
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77.  
  78.  
  79.  
  80. /****************************************************************************\
  81. *
  82. * Function:     int dmaAllocBuffer(unsigned size, dmaBuffer *buf);
  83. *
  84. * Description:  Allocates a DMA buffer (totally inside a 64K physical page)
  85. *
  86. * Input:        unsigned size           size of buffer in bytes
  87. *               dmaBuffer *buf          pointer to DMA buffer information
  88. *
  89. * Returns:      MIDAS error code. DMA buffer information is written to *buf.
  90. *
  91. \****************************************************************************/
  92.  
  93. int CALLING dmaAllocBuffer(unsigned size, dmaBuffer *buf);
  94.  
  95.  
  96.  
  97.  
  98. /****************************************************************************\
  99. *
  100. * Function:     int dmaFreeBuffer(dmaBuffer *buf);
  101. *
  102. * Description:  Deallocates an allocated DMA buffer
  103. *
  104. * Input:        dmaBuffer *buf          pointer to DMA buffer information
  105. *
  106. * Returns:      MIDAS error code
  107. *
  108. \****************************************************************************/
  109.  
  110. int CALLING dmaFreeBuffer(dmaBuffer *buf);
  111.  
  112.  
  113.  
  114.  
  115. /****************************************************************************\
  116. *
  117. * Function:     int dmaPlayBuffer(dmaBuffer *buf, unsigned channel,
  118. *                   unsigned autoInit);
  119. *
  120. * Description:  Plays a DMA buffer
  121. *
  122. * Input:        dmaBuffer *buf          pointer to DMA buffer information
  123. *               unsigned channel        DMA channel number
  124. *               unsigned autoInit       1 if autoinitializing DMA is used, 0
  125. *                                       if not
  126. *
  127. * Returns:      MIDAS error code
  128. *
  129. \****************************************************************************/
  130.  
  131. int CALLING dmaPlayBuffer(dmaBuffer *buf, unsigned channel,
  132.     unsigned autoInit);
  133.  
  134.  
  135.  
  136.  
  137. /****************************************************************************\
  138. *
  139. * Function:     int dmaStop(unsigned channel);
  140. *
  141. * Description:  Stops DMA playing
  142. *
  143. * Input:        unsigned channel        DMA channel number
  144. *
  145. * Returns:      MIDAS error code
  146. *
  147. \****************************************************************************/
  148.  
  149. int CALLING dmaStop(unsigned channel);
  150.  
  151.  
  152.  
  153.  
  154. /****************************************************************************\
  155. *
  156. * Function:     int dmaGetPos(dmaBuffer *buf, unsigned *pos);
  157. *
  158. * Description:  Reads the DMA playing position
  159. *
  160. * Input:        dmaBuffer *buf          pointer to DMA buffer information
  161. *               unsigned *pos           pointer to playing position
  162. *
  163. * Returns:      MIDAS error code. DMA playing position from the beginning
  164. *               of the buffer, in bytes, is written to *pos.
  165. *
  166. \****************************************************************************/
  167.  
  168. int CALLING dmaGetPos(dmaBuffer *buf, unsigned *pos);
  169.  
  170.  
  171.  
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177.  
  178.  
  179.  
  180. /****************************************************************************\
  181. *       enum dmaFunctIDs
  182. *       ----------------
  183. * Description:  ID numbers for DMA handling functions
  184. \****************************************************************************/
  185.  
  186. enum dmaFunctIDs
  187. {
  188.     ID_dmaAllocBuffer = ID_dma,
  189.     ID_dmaFreeBuffer,
  190.     ID_dmaPlayBuffer,
  191.     ID_dmaStop,
  192.     ID_dmaGetPos
  193. };
  194.  
  195.  
  196. #endif
  197.  
  198.  
  199. /*
  200.  * $Log: dma.h,v $
  201.  * Revision 1.2  1997/01/16 18:41:59  pekangas
  202.  * Changed copyright messages to Housemarque
  203.  *
  204.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  205.  * Initial revision
  206.  *
  207. */